﻿//
// Copyright (C) Ashish Kaila 2011
//

using System;
using System.Windows.Controls;
using System.Windows.Input;
using Flipbook.Commands;
using MixModes.Synergy.VisualFramework.Commands;

namespace Flipbook.Controls
{
    /// <summary>
    /// Interaction logic for RadialViewControl.xaml
    /// </summary>
    public partial class RadialViewControl : UserControl
    {
        /// <summary>
        /// Occurs when control is closed
        /// </summary>
        public event EventHandler Close;

        /// <summary>
        /// Initializes a new instance of the <see cref="RadialViewControl"/> class.
        /// </summary>
        public RadialViewControl()
        {
            CloseCommand = new CommandBase(arg =>
            {
                EventHandler closeEvent = Close;
                if (closeEvent != null)
                {
                    closeEvent(this, EventArgs.Empty);
                }
            },
            arg =>
            {
                // Ensures that user clicked on empty area and not listboxitem
                GestureCommandParameter parameter = arg as GestureCommandParameter;
                return (parameter.GestureEventArgs.OriginalSource is ScrollViewer);
            });

            InitializeComponent();
        }

        /// <summary>
        /// Gets the close command.
        /// </summary>
        public ICommand CloseCommand
        {
            get;
            private set;
        }
    }
}
